package utilitarios;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class JPanelPersonalizavel extends JPanel{
	
	private Paint texture;
	
	public JPanelPersonalizavel(String wallPaper){		
		try {
			BufferedImage image = ImageIO.read(new File (wallPaper));
			texture = new TexturePaint( image, new Rectangle(image.getWidth(), image.getHeight() ) ); 
		} catch (IOException e) {
			e.printStackTrace();
		}		
	}
	
    public void paintComponent( Graphics g )  
    {  
        super.paintComponent( g );  

        Graphics2D g2 = ( Graphics2D ) g;  
        g2.setPaint( texture );  
        g.fillRect( 0, 0, getWidth(), getHeight() );  
    }	
}
